package hou;

public class Test04 {
    public static void main(String[] args) throws ClassNotFoundException {
        People people = new Student();
        System.out.println(people);

        //通过对象获得
        Class c1 = people.getClass();

        //forname获得
        Class c2 = Class.forName("hou.People");

        //通过类名.class获得
        Class<Student> c3 = Student.class;
        //hashcode一样

        //获得父类
        Class c5 = c1.getSuperclass();
        System.out.println(c5);
    }
}

class People{
    private String name;

    public People() {
    }

    public People(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                '}';
    }
}

class Student extends People{
    public Student() {
        super("学生");
    }
}

class Teacher extends People{
    public Teacher() {
        super("Teacher");
    }
}
